const DataBaseconnections = require('../app/database')
class FileService {
  async saveAvatarInfo(filename, mimetype, size, userid) {
    const statement = `INSERT INTO avatar (filename,mimetype,size,user_id) VALUES(?,?,?,?);`
    // 将user存入数据库
    const results = await DataBaseconnections.execute(statement, [filename, mimetype, size, userid])
    return results
  }
  async getAvatarByUserid(userid){
    const statement = `SELECT * FROM avatar WHERE user_id = ?;`
    // 将user存入数据库
    const results = await DataBaseconnections.execute(statement, [userid])
    return results[0]
  }
}

module.exports = new FileService()
